<?php
    if(!defined('MVMMALL')){
        exit('Access Denied');
    }
    /* 配送方式插件的代码必须和文件名保持一致 */
    $shipping['stkd']['name']    = '申通快递';
    
    /* 配送方式的描述 */
    $shipping['stkd']['desc']    = '[运费较低，2～4天抵达。]';
    
    /* 不支持保价 */
    $shipping['stkd']['insure']  = 0;
    
    /* 配送方式是否支持货到付款 */
    $shipping['stkd']['cod']     = 0;
    
     /* 版权信息*/
    $shipping['stkd']['license']  = '版权所有www.mvmmall.com';

    /* 配送接口需要的参数 */
    $shipping['stkd']['cfg'] = array(
                                    array('name' => 'base_fee', 'value'=>15,'label'=>'1000克以内费用'),
                                    array('name' => 'step_fee', 'value'=>2,'label'=>'续重每1000克或其零数'),
                                );

class stkd
{
    var $cfg;
    
    /*配置信息*/
    function stkd($cfg = array())
    {
         foreach ($cfg AS $key=>$val)
        {
            $this->cfg[$val['name']] = $val['value'];
        }
    }
    /*计算费用*/
    function exes($kg,$price)
    {
        if ($this->cfg['free_money'] > 0 && $price >= $this->cfg['free_money'])
        {
            return 0;
        }
        else
        {
            $fee = $this->cfg['base_fee'];
            if ($kg > 1)
            {
                $fee += (ceil(($kg - 1))) * $this->cfg['step_fee'];
            }
            return $fee;
        }
    }

    /*询问定单*/
    function demand($sn)
    {
         $str = '<a href="http://www.sf-express.com/sfwebapp/track.jsp?tracklist='.$invoice_sn.'" target="_blank">' .$invoice_sn. '</a>';
        return $str;
    }
}